﻿Public Class SQLWindow 

    Private Sub TextEdit1_TextChanged(sender As System.Object, e As System.EventArgs) Handles OriginalSQL.TextChanged
        Dim oldText As String = String.Empty
        Dim newText As String = Me.OriginalSQL.Text

        'Replace LineFeed and Tabs by Empty spaces
        newText = newText.Replace(vbCrLf, " ")
        newText = newText.Replace(vbTab, " ")

        'Remove Double Spaces
        While newText <> oldText
            oldText = newText
            newText = newText.Replace("  ", " ")
        End While

        Me.FlattenSQL.Text = newText
    End Sub
End Class